<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/8/18
  Time: 11:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
    <TITLE>云和租房 - 用户管理</TITLE>
    <META content="text/html; charset=utf-8" http-equiv=Content-Type>
    <LINK
            rel=stylesheet type=text/css href="../css/style.css">
    <script src="scripts/jquery-1.8.3.js"></script>

    <META name=GENERATOR>
    <style type="text/css">
        dd{
            width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    </style>
</HEAD>
<BODY>
<DIV id=header class=wrap>
    <DIV id=logo><IMG src="../images/logo.gif"></DIV>
    <DIV class=search><LABEL class="ui-green searchs"><a href="/issue.jsp" title="">发布房屋信息</a></LABEL>
        <LABEL class=ui-green><INPUT onclick='document.location="/user/logout_userLogout"' value="退       出" type=button name=search></LABEL>
    </DIV>
</DIV>
<DIV class="main wrap">
    <DIV id=houseArea>
        <TABLE class=house-list>
            <TBODY>

            </TBODY>
        </TABLE>
    </DIV>

    <DIV class=pager>
        <UL>
            <LI class=current><A id="first"
                                 href="javascript:void(0)"
                                 parseContent="true" showError="true"
                                 ajaxAfterValidation="false" validate="false"
                                 dojoType="struts:BindAnchor">首页</A>
            </LI>
            <LI class=current><A id="prev"
                                 href="javascript:void(0)"
                                 parseContent="true" showError="true"
                                 ajaxAfterValidation="false" validate="false"
                                 dojoType="struts:BindAnchor">上一页</A>
            </LI>
            <LI class=current><A id="next"
                                 href="javascript:void(0)"
                                 parseContent="true" showError="true"
                                 ajaxAfterValidation="false" validate="false"
                                 dojoType="struts:BindAnchor">下一页</A>
            </LI>
            <LI class=current><A id="last"
                                 href="javascript:void(0)"
                                 parseContent="true" showError="true"
                                 ajaxAfterValidation="false" validate="false"
                                 dojoType="struts:BindAnchor">尾页</A>
            </LI>
        </UL>
        <SPAN id="total" class=total></SPAN></DIV>
</DIV>
<DIV id=footer class=wrap>
    <DL>
        <DT>云和租房 © 2010 云和 京ICP证1000001号</DT>
        <DD>关于我们 · 联系方式 · 意见反馈 · 帮助中心</DD>
    </DL>
</DIV>
</BODY>

<script>

    var totalPage; //总页数
    var currPageIndex; //当前页面
    $(function () {
        houseList(currPageIndex);
    })

    $("a").click(function () {
        var index = $(this).text(); //点击的连接名称
        if (index.trim() == "首页") {
            currPageIndex = 1;
        }
        if (index.trim() == "上一页") {
            currPageIndex--;
            if (currPageIndex < 1) { //若当前页面小于1,则将其赋值为1,反之该值越界
                currPageIndex = 1;
            }
        }
        if (index.trim() == "下一页") {
            currPageIndex++;
            if (currPageIndex > totalPage) { //当前页码大于总页码则返回总页码
                currPageIndex = totalPage;
            }
        }
        if (index.trim() == "尾页") {
            currPageIndex = totalPage;
        }
        houseList(currPageIndex);
    })


    var houseList = function(currPage) {
        $.ajax({
            type: "post",
            dataType: "JSON",
            url: "/house/getAllHouse_getAllHouseInfo",
            data: {currPage: currPage || 1},
            success: function (data) {
                $(".allhouse-list").remove(); //移除历史行
                totalPage = data.totalPage;
                currPageIndex = data.currPageIndex;
                $.each(data.houseList, function (index,obj) {
                    var tr = "<TR class='allhouse-list'>\n" +
                        "<TD class=house-thumb><SPAN><A A href=\\\"/house/getHouseById_getHouseById?house.hid=\"+obj.hid+\"\\\" target=\"_blank\"><img src=\"../images/" + obj.pic + "\"\n" +
                        "                                                                                       width=\"100\" height=\"75\"\n" +
                        "                                                                                       alt=\"暂无图片\"></A></SPAN></TD>\n" +
                        "                <TD>\n" +
                        "                    <DL>\n" +
                        "                        <DT><A href=\"/house/getHouseById_getHouseById?house.hid="+obj.hid+"\" target=\"_blank\">"+obj.title+"</A></DT>\n" +
                        "                        <DD>"+obj.describ+"<BR>联系方式："+obj.phone+"</DD>\n" +
                        "                    </DL>\n" +
                        "                </TD>\n" +
                        "                <TD class=house-type><LABEL class=ui-green><INPUT onclick=update(46) value=\"修    改\" type=button\n" +
                        "                                                                  name=search></LABEL></TD>\n" +
                        "                <TD class=house-price><LABEL class=ui-green><INPUT value=\"删    除\" type=button name=search></LABEL></TD>\n" +
                        "            </TR>";

                    $("TBODY").append(tr);
                });
                var msg = "第"+currPageIndex+"/"+totalPage+"页";
                $("#total").text(msg);
            }
        })
    }

</script>

</HTML>

